﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using WindowsGame.Components;

namespace WindowsGame.GameObjects
{
	public class GameObject
	{
		public GameObject()
		{
			Components = new Dictionary<String, BaseGameComponent>();
		}

		public virtual void LoadContent()
		{
			foreach (KeyValuePair<String, BaseGameComponent> component in Components)
			{
				component.Value.LoadContent();
			}
		}

		public void AddComponent(String name, BaseGameComponent gameComponent)
		{
			Components.Add(name, gameComponent);
		}

		public T GetComponent<T>() where T : BaseGameComponent
		{
			String name = typeof(T).Name;
			return Components.ContainsKey(name) ? (T)Components[name] : default(T);
		}

		public IDictionary<String, BaseGameComponent> Components { get; private set; }
	}
}